<template>
	<view>
		<view class="bg-white">
			<u-tabs :current="current" @click="clickTab" :scrollable="false" :list="list1" lineWidth="30"
				lineColor="#3389FF" :activeStyle="{
			            color: '#3389FF',
			            fontWeight: 'bold',
			            transform: 'scale(1.05)'
			        }" :inactiveStyle="{
			            color: '#606266',
			            transform: 'scale(1)'
			        }" itemStyle="padding-left: 15px; padding-right: 15px; height: 34px;">
			</u-tabs>
		</view>
		<view class="padding">
			<view @click="toInfo(item)" class="com-item" v-for="(item,index) in dataList" :key="index">
				<view style="background-color: #FD8A19;" class="com-state" v-if="item.state==1">待审核</view>
				<view style="background-color: #08B966;" class="com-state" v-if="item.state==0">审核通过</view>
				<view class="com-name">{{item.companyName}}</view>
				<view style="margin-bottom: 20rpx;" class="start_layout">
					<view class="cu-tag bg-blue light radius">{{item.industryName}}</view>
					<view v-for="(item1,index1) in item.qualificationNames.split(',')" :key="index1">
						<view class="cu-tag bg-orange light radius">{{item1}}</view>
					</view>
				</view>
				<view class="between_layout com-type solid-top">
					<view class="start_layout" style="line-height: 30rpx;">
						<view class="cuIcon-location type-icon"></view>{{item.registeredAddress}}
					</view>
					<view v-if="item.state==1">
						<u-button @click.native.stop="toAudit(item)" text="审核" type="error" size="mini"></u-button>
					</view>
				</view>
			</view>
		</view>
		<u-back-top :scroll-top="scrollTop"></u-back-top>
		<u-loadmore v-show="dataList.length>0" :status="status" />
		<auditPop ref="auditPopRef" @popSuccess="search" :type='1'></auditPop>
	</view>
</template>

<script>
	import {
		auditCompanyList
	} from '@/utils/api.js'
	export default {
		data() {
			return {
				current: 0,
				policyForm: {
					pageNum: 1,
					pageSize: 10,
					state: null
				},
				list1: [{
					name: '全部',
					state: null
				}, {
					name: '待审核',
					state: 1
				}, {
					name: '审核通过',
					state: 0
				}],
				status: 'nomore',
				total: 0,
				dataList: [],
				scrollTop: 0
			}
		},
		onLoad(option) {
			if (option.isAudit == 1) {
				this.policyForm.state = 1
				this.current = 1
			} else {
				this.policyForm.state = null
			}
		},
		onShow() {
			this.search()
		},
		onReachBottom() {
			if (this.policyForm.pageNum >= this.total / 10) {
				this.status = 'nomore'
				return
			} else {
				this.status = 'loading'
				this.policyForm.pageNum++
				this.init()
			}
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},
		methods: {
			init() {
				uni.showLoading({
					title: '加载中'
				});
				auditCompanyList(this.policyForm).then(response => {
					if (response.code == 200) {
						uni.hideLoading();
						this.dataList = [...this.dataList, ...response.rows]
						this.total = response.total
					} else {
						uni.hideLoading();
						uni.showToast({
							title: response.msg,
							icon: 'none',
							duration: 3000
						})
					}
					this.status = 'nomore'
				});
			},
			clickTab(item) {
				this.policyForm.state = item.state
				this.policyForm.pageNum = 1
				this.dataList = []
				this.init()
			},
			toInfo(item) {
				uni.navigateTo({
					url: '/pages_two/mine/company/authSubmit?id=' + item.baseId
				})
			},
			toAudit(item) {
				this.$refs.auditPopRef.openPop(item.baseId)
			},
			search() {
				this.policyForm.pageNum = 1
				this.dataList = []
				this.init()
			}
		}
	}
</script>
<style lang="scss" scoped>
	.com-item {
		background: #FFFFFF;
		border-radius: 10rpx;
		padding: 28rpx;
		margin-bottom: 28rpx;
		position: relative;

		.com-state {
			position: absolute;
			top: 0;
			right: 0;
			padding: 6rpx 14rpx;
			border-radius: 0rpx 10rpx 0rpx 10rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			font-size: 24rpx;
			color: #FFFFFF;
		}

		.com-name {
			font-family: PingFang SC, PingFang SC;
			font-weight: bold;
			font-size: 30rpx;
			color: #333333;
			line-height: 46rpx;
			margin-bottom: 20rpx;
			margin-right: 80rpx;
		}

		.cu-tag {
			margin-right: 10rpx;
			margin-bottom: 10rpx;
		}

		.com-type {
			padding-top: 28rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			font-size: 28rpx;
			color: #999999;
			line-height: 24rpx;
		}
	}
</style>